public class Main {
    public void remove(int key){
        while(cur!=NULL){
            if(cur.val==key){
                prev.next=cur.next;
                cur=cur.next;
            }
            else{
                prev=cur;
                cur=cur.next;
            }
        }
        if(head.val==key){
            head=head.next;
        }
    }

    public ListNode middleNode(ListNode head){
        ListNode fast=head;
        ListNode slow=head;
        if(fast!=null&&fast.next!=null){
            fast=fast.next.next;
            slow=slow.next;
        }
         return slow;
    }
}